package com.itheima.collectionDemo;

import java.util.ArrayList;
import java.util.Collection;
import java.util.function.Consumer;

public class CollectionDemo1 {
    public static void main(String[] args) {
        Collection<String> coll = new ArrayList<>();
        coll.add("Zhangsan");
        coll.add("Lisi");
        coll.add("Wangwu");

        // 匿名内部类
        coll.forEach(new Consumer<String>() {
            @Override
            // s依次表示集合中的每一个数据
            public void accept(String s) {
                System.out.println(s);
            }
        });

        // Lambda
        coll.forEach(s -> System.out.println(s));
        coll.forEach(System.out::println);
    }
}
